package com.wolfeyes.common.utils.network.webpage;

import java.util.LinkedHashMap;
import java.util.Map;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * @description 获取前端查询参数信息(paramsMap)的封装类
 * @projectName film
 * @className Query.java
 * @author yanyljava
 * @email yanyljava@qq.com
 * @date 2018-11-25 10:54:58
 * @since 2018年07月12日上午11:37:39
 * @createTime 2018年07月15日 上午10:04:13
 * @version 1.0.0
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper=false)
public class Query extends LinkedHashMap<String, Object> {
	
	// 序列化ID；
	private static final long serialVersionUID = -3082156934657068004L;
	
	private int offset;					// 开始索引
	
	private int limit;					// 每页条数
	

	public Query(Map<String, Object> params) {
		this.putAll(params);
		// 分页参数
		this.offset = Integer.parseInt(params.get("offset").toString());
		this.limit = Integer.parseInt(params.get("limit").toString());
		this.put("offset", offset);
		this.put("page", offset / limit + 1);
		this.put("limit", limit);
	}

	public void setOffset(int offset) {
		this.put("offset", offset);
	}
	
}


